package middlewares

import (
	"github.com/gin-gonic/gin"
	"log"
	"time"
)

func Logger() gin.HandlerFunc {
	return func(c *gin.Context) {
		t := time.Now()
		//log.Print("222")
		// 设置 example 变量
		var userId string = "1"
		c.Set("UserId", userId)
		//c.SetCookie("name", "131231231231", 1211, "/", "localhost", false, true)

		// 请求前
		c.Next()
		// 请求后
		latency := time.Since(t)
		log.Print(latency)
		// 获取发送的 status
		status := c.Writer.Status()
		log.Println(status)
		//c.SetCookie("cookiessss", "11111", 3600, "/", "localhost", false, true)
		//设置userId

	}
}
